﻿<?php	

try{

	$name = $_POST['nome'];
	$phone = $_POST['fone'];
	$from = $_POST['email'];
	$subject = $_POST['assunto'];
	$message = $_POST['mensagem'];

	if(empty($name)){
		echo "Por favor, verifique o nome informado.";
	}elseif (checkMail($from) == false){
		echo " Por favor, verifique o email informado.";
	}elseif(empty($subject)){
		echo "Por favor, verifique o assunto informado.";
	}elseif(empty($message)){
		echo "Por favor, verifique a mensagem informada";
	}else{

		$message = $message . "\n\nNome: " . $name;
		$message = $message . "\nFone: " . $phone;

		$subject = "[Site] " . $subject;
		$to = "contato@logicart.com.br, " . $from;

		$headers = "MIME-Version: 1.0";
		$headers .= "Content-type: text/plain; charset=UTF-8\r\n";
		$headers .= "Organization: LogicArt\r\n";
		$headers .= "X-Priority: 3\r\n";
		$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
		$headers .= "From: ".$name." <".$from.">\r\n";
		$headers .= "Reply-To: " . $name . " <" . $from . ">\r\n";
		$headers .= "Return-Path: " . $name . " <" . $from . ">";

		// 		echo mail($to, $subject, $message, $headers);
		echo true;

	}

}catch(Exception $e){
	echo $e->getMessage();
}

function checkMail($email) {
	$expression = '/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/';
	return preg_match($expression, $email);
}

?>